package com.taoding.hfhclient.netty_client;

import com.google.common.collect.Lists;
import com.taoding.hfhclient.common.Constants;
import com.taoding.hfhclient.netty_client.service.NettyClientMessageImpl;
import com.taoding.hfhclient.netty_client.service.NettyClientMessageService;
import com.taoding.hfhclient.rabbitmq.MQConfig;
import org.joda.time.DateTime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @author liuxinghong
 * @Description:
 * @date 2019/9/2 000217:46
 */
@Component
public class NettyClientTest {

    @Autowired
    private NettyClientMessageService api;

    @Scheduled(cron = "0/1 * * * * ? ")
    public  void sendMessage(){
        System.out.println("开始发送........");
        MessageDTO message = MessageDTO.builder().type(NettyConfig.NETTY_COMMON_TYPE)
                .messageBody("发送业务消息到服务端")
                .senderId(MQConfig.keys)
                .sendTime(DateTime.now().toString(Constants.YYYY_MM_DD_HH_MM_SS))
                .receiveIds(NettyConfig.NETTY_SERVER_ID).build();
        api.sendMessage(Lists.newArrayList(message));
    }



}
